package com.gqzmy.springboot3.exceptions;

import org.springframework.http.HttpStatus;

import java.io.Serial;

/**
 * @author 周小哥  gqzmy@163.com 2023/4/24 10:05
 */

public class SystemApiException extends SystemException {
    @Serial
    private static final long serialVersionUID = -5437414821726412807L;


    private String detailErrCode;

    private String errAbstract;

    public static SystemApiException create() {
        return new SystemApiException();
    }

    public SystemApiException overview(ErrorOverview errorOverView) {
        this.detailErrCode = errorOverView.getErrorCode();
        this.errAbstract = errorOverView.getErrorMessage();
        return this;
    }

    public SystemApiException message(String message) {
        this.setErrMsg(message);
        return this;
    }

    public SystemApiException status(HttpStatus status) {
        this.setErrCode(status.value());
        return this;
    }

    public String getDetailErrCode() {
        return detailErrCode;
    }

    public String getErrAbstract() {
        return errAbstract;
    }

    @Override
    public String toString() {
        return "SystemApiException{" +
                "detailErrCode='" + detailErrCode + '\'' +
                ", errAbstract='" + errAbstract + '\'' +
                '}';
    }
}
